<?php

  $data = array();
  //print_r($_GET);
  $key = $_GET['key'];

  /*根据点击激活链接提交的key作为查询条件，查询该key在menber表的id，判断存在时间是否过期，如果没过期则修改menber表中该id下的status值*/
  $sql = "select `menber_id`,`cookie_time` from `tmep` where `key`='$key'";

  $rel = mysqli_query($link,$sql);

  while($dd=mysqli_fetch_assoc($rel)){
        $data=$dd;
  }


  $id = $data['menber_id'];
  $cookie_time = $data['cookie_time'];
  $time = time();

  if($time>$cookie_time){
    echo "激活链接已超时,是否重新发送？ <a href='#'>点击重新发送</a>";

  }else{
    $sqla="update `menber` set `status`=1 where `id`=$id";
    mysqli_query($link,$sqla);
    $rows = mysqli_affected_rows($link);
    if($rows>0){
      echo "激活成功；<a href='index.php?c=admin&a=login&admin=1'>跳转至登录页...</a>";
      $sqlb = "delete from `tmep` where `menber_id`=$id";
      mysqli_query($link,$sqlb);
    }else{
      echo "激活失败,或则您已激活账户";
    }

  }


?>